home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Micromail 103 / MicroMail.jar / MessageForm.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-09-07  |  2.9 KB  |  91 lines

  1. import javax.microedition.lcdui.Command;
  2. import javax.microedition.lcdui.CommandListener;
  3. import javax.microedition.lcdui.Displayable;
  4. import javax.microedition.lcdui.Form;
  5. import javax.microedition.lcdui.TextField;
  6.  
  7. public class MessageForm extends Form implements CommandListener {
  8.    private MicroMail midlet;
  9.    private Displayable parent;
  10.    private Message message;
  11.    private int activeMsgId;
  12.    TextField txtTo;
  13.    TextField txtSubject;
  14.    TextField txtBody;
  15.    Command backCommand = new Command(Resource.getText(1), 2, 3);
  16.    Command saveCommand = new Command(Resource.getText(2), 1, 1);
  17.    Command aBookCommand = new Command(Resource.getText(12), 1, 2);
  18.  
  19.    public MessageForm(MicroMail var1, Displayable var2, Message var3, int var4) {
  20.       super(Resource.getText(25));
  21.       this.midlet = var1;
  22.       this.parent = var2;
  23.       this.message = var3;
  24.       this.activeMsgId = var4;
  25.       ((Displayable)this).setCommandListener(this);
  26.       ((Displayable)this).addCommand(this.backCommand);
  27.       ((Displayable)this).addCommand(this.saveCommand);
  28.       ((Displayable)this).addCommand(this.aBookCommand);
  29.       this.displayFields();
  30.    }
  31.  
  32.    public void addAddress(String var1) {
  33.       String var2 = this.txtTo.getString();
  34.       if (var2.length() > 0) {
  35.          var2 = var2 + ";";
  36.       }
  37.  
  38.       this.txtTo.setString(var2 + var1);
  39.    }
  40.  
  41.    public void commandAction(Command var1, Displayable var2) {
  42.       if (var1 == this.backCommand) {
  43.          MicroMail.display.setCurrent(this.parent);
  44.       } else if (var1 == this.aBookCommand) {
  45.          AddressList var3 = new AddressList(this.midlet, this);
  46.          MicroMail.display.setCurrent(var3);
  47.       } else if (var1 == this.saveCommand) {
  48.          if (this.message == null) {
  49.             this.message = new Message();
  50.          }
  51.  
  52.          this.message.to = this.txtTo.getString();
  53.          this.message.subject = this.txtSubject.getString();
  54.          this.message.body = this.txtBody.getString();
  55.          MicroCache.storeMessage(2, this.message, this.activeMsgId);
  56.          if (this.parent instanceof MessageList) {
  57.             MessageList var4 = (MessageList)this.parent;
  58.             if (var4.activeBoxId == 2) {
  59.                if (this.activeMsgId > -1) {
  60.                   var4.updateItem(this.activeMsgId, this.message.subject, this.message.unread ^ true);
  61.                } else {
  62.                   var4.appendItem(this.message.subject);
  63.                }
  64.             }
  65.          }
  66.  
  67.          this.message = null;
  68.          MicroMail.display.setCurrent(this.parent);
  69.       }
  70.  
  71.    }
  72.  
  73.    public void displayFields() {
  74.       String var1 = "";
  75.       String var2 = "";
  76.       String var3 = "";
  77.       if (this.message != null) {
  78.          var1 = this.message.to;
  79.          var2 = this.message.subject;
  80.          var3 = this.message.body;
  81.       }
  82.  
  83.       this.txtTo = new TextField(Resource.getText(26), var1, 300, 0);
  84.       this.txtSubject = new TextField(Resource.getText(29), var2, 50, 0);
  85.       this.txtBody = new TextField(Resource.getText(30), var3, 1000, 0);
  86.       ((Form)this).append(this.txtTo);
  87.       ((Form)this).append(this.txtSubject);
  88.       ((Form)this).append(this.txtBody);
  89.    }
  90. }
  91.